//*******************************************************************       //
//IMPORTANT NOTICE                                                          //
//================                                                          //
//Copyright Mentor Graphics Corporation 1996 - 1999.  All rights reserved.  //
//This file and associated deliverables are the trade secrets,              //
//confidential information and copyrighted works of Mentor Graphics         //
//Corporation and its licensors and are subject to your license agreement   //
//with Mentor Graphics Corporation.                                         //
//                                                                          //
//Use of these deliverables for the purpose of making silicon from an IC    //
//design is limited to the terms and conditions of your license agreement   //
//with Mentor Graphics If you have further questions please contact Mentor  //
//Graphics Customer Support.                                                //
//                                                                          //
//This Mentor Graphics core (m8051w v2002.080) was extracted on             //
//workstation hostid 8316cbec Inventra                                      //
// Program Counter Increment and Relative Offset Generator for M8051W/EW
// 
// $Log: m3s011dy.v,v $
// Revision 1.5  2001/11/20
// First checkin of version 2 features and name change
//
// Revision 1.2  2001/10/31
// First parsable verilog for EW
//
// Revision 1.1.1.1  2001/07/17
// Re-imported E-Warp from Farnham filesystem
//
// Revision 1.4  2000/10/24
// Multiplier rewritten to improve power consumption.
// Code changes for Leonardo (ECN01372).
// Code changes for formal verification tools (ECN01410).
// MOVX @Ri page address controllable from PORT2I if I/O ports ommitted (ECN01387).
//
// Revision 1.3  2000/02/05
// Name change repercussions
//
// Revision 1.2  1999/11/30
// More debug changes.
//
// Revision 1.1.1.1  1999/10/28
// "initialization and source check-in for m8051e"
//
// Revision 1.1  1999/10/22
// Initial revision
//
////////////////////////////////////////////////////////////////////////////////

module m3s011dy (PC_SUM, OPERAND_16, OPERAND_8, INCREMENT, SIGN_EXTEND);
//*******************************************************************       //
//IMPORTANT NOTICE                                                          //
//================                                                          //
//Copyright Mentor Graphics Corporation 1996 - 1999.  All rights reserved.  //
//This file and associated deliverables are the trade secrets,              //
//confidential information and copyrighted works of Mentor Graphics         //
//Corporation and its licensors and are subject to your license agreement   //
//with Mentor Graphics Corporation.                                         //
//                                                                          //
//Use of these deliverables for the purpose of making silicon from an IC    //
//design is limited to the terms and conditions of your license agreement   //
//with Mentor Graphics If you have further questions please contact Mentor  //
//Graphics Customer Support.                                                //
//                                                                          //
//This Mentor Graphics core (m8051w v2002.080) was extracted on             //
//workstation hostid 8316cbec Inventra                                      //

  output [15:0] PC_SUM;
  input  [15:0] OPERAND_16;
  input  [7:0]  OPERAND_8;
  input  INCREMENT, SIGN_EXTEND;          // Increment is the default operation.
                                          // Sign extension used for addition of
                                          // 8-bit signed operands to 16-bit
                                          // operands, in relative jump ops.

  reg    [15:0] PC_GEN, PC_PROP;
  reg           PROP_3, PROP_7, PROP_11;
  reg           GEN_3, GEN_7, GEN_11;
  reg           CARRY_4, CARRY_8, CARRY_12;

  // First produce single bit sum and carry products
  // 8-bit operand is sign extended for relative jumps.

  always @(OPERAND_16 or OPERAND_8 or SIGN_EXTEND)
  begin: p_bit_slice
    PC_GEN[7:0]   <= OPERAND_16[7:0]  & OPERAND_8[7:0]; 
    PC_GEN[15:8]  <= OPERAND_16[15:8] & {8{SIGN_EXTEND & OPERAND_8[7]}}; 

    PC_PROP[7:0]  <= OPERAND_16[7:0]  ^ OPERAND_8[7:0]; 
    PC_PROP[15:8] <= OPERAND_16[15:8] ^ {8{SIGN_EXTEND & OPERAND_8[7]}}; 
  end

  // These are the carry look-ahead terms.

  always @(PC_PROP or PC_GEN)
  begin: p_prop_gen
    PROP_3  <= &PC_PROP[3:0];
    PROP_7  <= &PC_PROP[7:4];
    PROP_11 <= &PC_PROP[11:8];

    GEN_3   <= PC_GEN[3]                      || PC_GEN[2] && PC_PROP[3]      ||
               PC_GEN[1] && (&PC_PROP[3:2])   || PC_GEN[0] && (&PC_PROP[3:1]);

    GEN_7   <= PC_GEN[7]                      || PC_GEN[6] && PC_PROP[7]      ||
               PC_GEN[5] && (&PC_PROP[7:6])   || PC_GEN[4] && (&PC_PROP[7:5]);
 
    GEN_11 <=  PC_GEN[11]                     || PC_GEN[10] && PC_PROP[11]    ||
               PC_GEN[9] && (&PC_PROP[11:10]) || PC_GEN[8] && (&PC_PROP[11:9]);
  end

  always @(GEN_3 or GEN_7 or GEN_11 or PROP_3 or PROP_7 or PROP_11 or INCREMENT)
  begin: p_carry

    CARRY_4  <= GEN_3  || INCREMENT && PROP_3;
    CARRY_8  <= GEN_7  || GEN_3 && PROP_7  || INCREMENT && PROP_3 && PROP_7;
    CARRY_12 <= GEN_11 || GEN_7 && PROP_11 || GEN_3 && PROP_7 && PROP_11 ||
                INCREMENT && PROP_3 && PROP_7 && PROP_11;
  end

  // 4-bit carry look-ahead cells
  m3s002dy u1 (.S(PC_SUM[3:0]), .P(PC_PROP[3:0]), .G(PC_GEN[2:0]),
               .C_IN(INCREMENT), .C_EN(1'b1));
  m3s002dy u2 (.S(PC_SUM[7:4]), .P(PC_PROP[7:4]), .G(PC_GEN[6:4]),
               .C_IN(CARRY_4), .C_EN(1'b1));
  m3s002dy u3 (.S(PC_SUM[11:8]), .P(PC_PROP[11:8]), .G(PC_GEN[10:8]),
               .C_IN(CARRY_8), .C_EN(1'b1));
  m3s002dy u4 (.S(PC_SUM[15:12]), .P(PC_PROP[15:12]), .G(PC_GEN[14:12]),
               .C_IN(CARRY_12), .C_EN(1'b1));

endmodule
